package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.entity.HomeBanner;
import com.ruoyi.common.core.domain.entity.Section;
import com.ruoyi.common.core.domain.entity.CommonDelete;
import com.ruoyi.common.core.page.CommonQuery;
import com.ruoyi.system.mapper.SectionMapper;
import com.ruoyi.system.service.ISectionService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author linxz
 * @since 2024-12-25
 */
@Service
public class SectionServiceImpl extends ServiceImpl<SectionMapper, Section> implements ISectionService {

    @Override
    public List<Section> selectList(CommonQuery commonQuery) {
        return baseMapper.selectListByPc(commonQuery.getDeviceType(),commonQuery.getLocate());
    }

    public List<Section> select(String deviceType,String locate){
        return baseMapper.select(deviceType,locate);
    }

    @Override
    public int add(Section section) {
        // 判断模块名称是否重复
        List<Section> list=baseMapper.isMulti(section.getSectionName());
        if(list==null || list.size()==0){
            //不重复，可以添加
            // 返回影响行数

            return baseMapper.insertEntity(section);
        }else {
            return 0;
        }



    }

    // 返回影响行数
    @Override
    public int update(Section section) {
        return baseMapper.updateEntity(section);
    }

    // 返回影响行数
    @Override
    public int delete(CommonDelete commonDelete) {
        return baseMapper.deleteById(commonDelete.getId());
    }




}
